package cn.elane.elastic.global.util;

import java.util.UUID;

/**
 * @author Chenuu
 */
public class StringUtil {

	public static boolean isEmpty(String str) {
		return (str == null || "".equals(str));
	}

	/**
	 * 获取36位UUID字符串
	 *
	 * @return uuid
	 */
	public static String getSourceUUID() {
		return UUID.randomUUID().toString();
	}

	/**
	 * 获取32位大写UUID
	 *
	 * @return UUID
	 */
	public static String getSortUpperUUID() {
		return UUID.randomUUID().toString().toUpperCase().replace("-", "");
	}

	/**
	 * 获取36位大写UUID
	 *
	 * @return UUID
	 */
	public static String getUpperUUID() {
		return UUID.randomUUID().toString().toUpperCase();
	}

	/**
	 * 获取32位UUID
	 *
	 * @return UUID
	 */
	public static String getSortUUID() {
		return UUID.randomUUID().toString().replace("-", "");
	}

	/**
	 * 根据Unicode编码完美的判断中文汉字和符号
	 */
	private static boolean isChinese(char c) {
		Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
		return ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
				|| ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
				|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
				|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
				|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
				|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
				|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION;
	}

	public static void main(String[] args) {
		/*System.out.println(getSourceUUID());
		System.out.println(getSortUUID());
		System.out.println(getSortUpperUUID());
		System.out.println(getUpperUUID());

		System.out.println(UUID.randomUUID().toString());
		System.out.println(UUID.randomUUID().toString().toUpperCase());*/
	}

}
